/************************************************************************************
**  
* @copyright (c) 2015-, Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file     duye_cap_filter_engine.h
* @version     
* @brief      
* @author   
* @date     2013-04-02
* @note 
*
*  1. 2018-04-02 created this file
* 
*/
#pragma once

#include <duye_cap_filter.h>
#include <duye_cap_packet.h>

namespace duye {

/**
 * @brief filter engine
 */
class FilterEngine : public Singleton<FilterEngine> {
public:
	FilterEngine() {}
	~FilterEngine() {}

	/**
	 * @brief filter packet
	 * @return true/false
	 * @note match OK return true
	 */	
	bool filterPkt(const PacketReference& pktRef, FilterRule* rule);

private:
	bool generalFilter(const PacketReference& pktRef, const FilterRule& rule);
	bool whiteRuleFilter(const PacketReference& pktRef, const RuleItemList& whiteRuleList);
	bool blackRuleFilter(const PacketReference& pktRef, const RuleItemList& blackRuleList);
};

}
